home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / v10n12.arc / GRAYBIT.C < prev    next >
Text File  |  1991-05-30  |  2KB  |  51 lines

  1.  
  2. HBITMAP GrayBit (HDC hdc)
  3.      {
  4.      static BYTE bData[8] = { 0x01, 0x23, 0x45, 0x67,
  5.                               0x89, 0xAB, 0xCD, 0xEF } ;
  6.      BITMAPINFO  *pbmi ;
  7.      HBITMAP     hBitmap ;
  8.      int         i ;
  9.  
  10.                // Allocate memory for the BITMAPINFO structure
  11.  
  12.      pbmi = malloc (sizeof (BITMAPINFOHEADER) + 16 * sizeof (RGBQUAD)) ;
  13.  
  14.      if (pbmi == NULL)
  15.           return NULL ;
  16.  
  17.                // Initialize it for a 16-color 1-row by 16-column bitmap
  18.  
  19.      pbmi->bmiHeader.biSize          = sizeof (BITMAPINFOHEADER) ;
  20.      pbmi->bmiHeader.biWidth         = 16 ;
  21.      pbmi->bmiHeader.biHeight        = 1 ;
  22.      pbmi->bmiHeader.biPlanes        = 1 ;
  23.      pbmi->bmiHeader.biBitCount      = 4 ;
  24.      pbmi->bmiHeader.biCompression   = BI_RGB ;  // no compression
  25.      pbmi->bmiHeader.biSizeImage     = 0 ;
  26.      pbmi->bmiHeader.biXPelsPerMeter = 0 ;
  27.      pbmi->bmiHeader.biYPelsPerMeter = 0 ;
  28.      pbmi->bmiHeader.biClrUsed       = 0 ;
  29.      pbmi->bmiHeader.biClrImportant  = 0 ;
  30.  
  31.                // Initialize the color table for 16 gray shades
  32.  
  33.      for (i = 0 ; i < 16 ; i++)
  34.           {
  35.           pbmi->bmiColors[i].rgbBlue     = (BYTE) (16 * i) ;
  36.           pbmi->bmiColors[i].rgbGreen    = (BYTE) (16 * i) ;
  37.           pbmi->bmiColors[i].rgbRed      = (BYTE) (16 * i) ;
  38.           pbmi->bmiColors[i].rgbReserved = 0 ;
  39.           }
  40.                // Create the bitmap
  41.  
  42.      hBitmap = CreateDIBitmap (hdc, &pbmi->bmiHeader, CBM_INIT,
  43.                                bData, pbmi, DIB_RGB_COLORS) ;
  44.                // Clean up
  45.  
  46.      free (pbmi) ;
  47.      return hBitmap ;
  48.      }
  49.  
  50.  
  51.